﻿using CZBK.ShopHeima2.BLL;
using CZBK.ShopHeima2.IBLL;
using CZBK.ShopHeima2.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace CZBK.ShopHeima2.UI.MainPortal.Controllers
{
    public class UserInfoController : Controller
    {
        IUserInfoService uService = new UserInfoService();
        //
        // GET: /UserInfo/

        public ActionResult Index()
        {
            ViewData.Model = uService.LoadAllEntities(u => u.Id > 0);
            return View();
        }
        public ActionResult Create()
        {
            return View();
        }
        [HttpPost]
        public ActionResult Create(UserInfo userInfo)
        {
            uService.AddEntity(userInfo);
            uService.SavaChanges();
            return RedirectToAction("index");
        }
        public ActionResult Edit(int id)
        {
            //ViewData["CurrentId"] = id;
            return View();
        }
        [HttpPost]
        public ActionResult Edit(UserInfo userInfo)
        {
            uService.UpdateEntity(userInfo);
            uService.SavaChanges();
            return RedirectToAction("index");
        }
        public ActionResult Delete()
        {
            return View();
        }
        [HttpPost]
        public ActionResult Delete(int id)
        {
            uService.DeleteEntity(id);
            uService.SavaChanges();
            return RedirectToAction("index");
        }
        public ActionResult Details(int id)
        {
            return View();
        }
    }
}
